package lt.vu.mif.os.processors;

import lt.vu.mif.os.RealMachineFrame;
import lt.vu.mif.os.provider.Constants;
/**
* @author Antanas Rudaitis
* @author Laurynas Paradauskas
* @author Algirdas Šaltupis
* 
*/
public class RealMachineRegisters implements Constants {

    private char[] ptr = new char[ptrSize];
    private int sp;
    private int pc;
    private boolean mode;
    private int ti;
    private byte si;
    private byte pi;

    //konstruktorius
    public RealMachineRegisters(){
        this.ptr = "0000".toCharArray();
        this.sp = 0;
        this.pc = 0;
        this.mode = false;
        this.ti = 0;
        this.si = 0;
        this.pi = 0;
    }

    //nunulintojas
    public void flush(){
        this.ptr = "0000".toCharArray();
        this.sp = 0;
        this.pc = 0;
        this.mode = false;
        this.ti = 0;
        this.si = 0;
        this.pi = 0;
    }
    
    public void updateGUIReg(RealMachineFrame rmFrame) {
    	rmFrame.updateModeField(Boolean.toString(mode));
    	rmFrame.updatePCField(Integer.toString(pc));
    	rmFrame.updatePIField(Integer.toString(pi));
    	rmFrame.updatePTRField(new String(ptr));
    	rmFrame.updateSIField(Integer.toString(si));
    	rmFrame.updateSPField(Integer.toString(sp));
    	rmFrame.updateTIField(Integer.toString(ti));
    }

    //get'eriai
    public char[] getPtr(){
        return this.ptr;
    }
    public int getSp(){
        return this.sp;
    }
    public int getPc(){
        return this.pc;
    }
    public boolean getMode(){
        return this.mode;
    }
    public int getTi(){
        return this.ti;
    }
    public int getSi(){
        return this.si;
    }
    public int getPi(){
        return this.pi;
    }

    //set'eriai
    public void setPtr(char[] ptr){
        this.ptr = ptr;
    }
    public void setSp(int sp){
        this.sp = sp;
    }
    public void setPc(int pc){
        this.pc = pc;
    }
    public void setMode(boolean mode){
        this.mode = mode;
    }
    public void setTi(int ti){
        this.ti = ti;
    }
    public void setSi(byte si){
        this.si = si;
    }
    public void setPi(byte pi){
        this.pi=pi;
    }
}
